/*
   aac encoder interface functions
 */
#ifndef _aacenc_h_
#define _aacenc_h_

#ifndef Word16
  #define Word16 short
#endif

#ifndef Word32
  #define Word32 int
#endif

#ifndef UWord8
  #define UWord8  unsigned char
#endif

#ifndef UWord16
  #define UWord16 unsigned short
#endif

#ifndef UWord32
  #define UWord32 unsigned int
#endif
 
/* here we distinguish between stereo and the mono only encoder */
#ifdef MONO_ONLY
#define MAX_CHANNELS        1
#else
#define MAX_CHANNELS        2
#endif

#define AACENC_BLOCKSIZE    1024   /*! encoder only takes BLOCKSIZE samples at a time */
#define AACENC_TRANS_FAC    8      /*! encoder short long ratio */
#define AACENC_PCM_LEVEL    1.0    /*! encoder pcm 0db refernence */


/*-------------------------- defines --------------------------------------*/


/*-------------------- structure definitions ------------------------------*/
struct AAC_ENCODER;

typedef enum {
    AU_QualityExcellent   = 0, 
    AU_QualityHigh        = 1, 
    AU_QualityMedium      = 2, 
    AU_QualityLow         = 3, 
} AuQuality;

typedef enum {
    AACLC    = 0,                /* AAC LC */
    EAAC     = 1,                /* eAAC  (HEAAC or AAC+  or aacPlusV1) */
    EAACPLUS = 2,                /* eAAC+ (AAC++ or aacPlusV2) */
} AuEncoderFormat; 

typedef  struct {
  AuQuality quality;
  AuEncoderFormat coderFormat;
  Word16    bitsPerSample;  
  Word32    sampleRate;            /* audio file sample rate */
  Word32    bitRate;               /* encoder bit rate in bits/sec */
  Word16    nChannelsIn;           /* number of channels on input (1,2) */
  Word16    nChannelsOut;          /* number of channels on output (1,2) */
  Word16    bandWidth;             /* targeted audio bandwidth in Hz */
} AACENC_CONFIG;



/*-----------------------------------------------------------------------------

functionname: AacInitDefaultConfig
description:  gives reasonable default configuration
returns:      ---

------------------------------------------------------------------------------*/
void AacInitDefaultConfig(AACENC_CONFIG *config);

/*---------------------------------------------------------------------------

functionname:AacEncOpen
description: allocate and initialize a new encoder instance
returns:     AACENC_OK if success

---------------------------------------------------------------------------*/
Word16  AacEncOpen(  struct AAC_ENCODER**   phAacPlusEnc,      /* pointer to an encoder handle, initialized on return */
                            AACENC_CONFIG   *pconfig           /* pre-initialized config struct */
                      );


Word16 AacEncEncode(struct AAC_ENCODER* hAacPlusEnc, /*!< an encoder handle */
                    Word16 *timeSignal,          /*!< BLOCKSIZE*nChannels audio samples, interleaved */
					UWord8 *outBytes,           /*!< pointer to output buffer (must be 6144/8*MAX_CHANNELS bytes large) */
                    Word32 *numOutBytes         /*!< number of bytes in output buffer after processing */
                    );

void AacEncClose (struct AAC_ENCODER *hAacPlusEnc);  

#endif /* _aacenc_h_ */
